package com.yyge.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.yyge.common.vo.resp.PageResp;
import com.yyge.controller.admin.product.req.ProductAddReq;
import com.yyge.controller.admin.product.req.ProductReq;
import com.yyge.controller.admin.product.resp.ProductResp;
import com.yyge.entity.Product;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
* @author Administrator
* @description 针对表【product(商品信息)】的数据库操作Service
* @createDate 2023-07-02 20:36:22
*/
public interface ProductService extends IService<Product> {

    PageResp search(ProductReq req);

    Product addProduct(ProductAddReq req);

    ProductResp searchById(ProductReq req, String id);

    ProductResp lockById(Long dishId);

    /**
     * 更新库存
     * @param id
     * @param num
     * @return
     */
    @Update(value = "update product set num=#{num} where id=#{id}} ")
    int subNumber(@Param(value = "id") Long id,@Param(value = "num") int num);


    /**
     * 更新库存
     * @param id 商品ID
     * @param num 数量
     * @return
     */
    int descNum(@Param(value = "id") Long id, @Param(value = "num")int num);
}
